package servlet;

import model.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created by xiebang
 * Description
 * User:小谢
 * Date:2022-03-11
 * Time:16:20
 */
public class Util {
    public static User checkLogin(HttpServletRequest req){
        HttpSession session = req.getSession(false);
        if (session == null){
//            未登录
            return null;
        }

        User user = (User) session.getAttribute("user");
        if (user == null){
//            未登录
            return null;
        }
        return user;
    }
}
